1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module soup.Request; 26 27 private import gio.AsyncResultIF; 28 private import gio.Cancellable; 29 private import gio.InitableIF; 30 private import gio.InitableT; 31 private import gio.InputStream; 32 private import glib.ErrorG; 33 private import glib.GException; 34 private import glib.Str; 35 private import glib.c.functions; 36 private import gobject.ObjectG; 37 private import soup.Session; 38 private import soup.URI; 39 private import soup.c.functions; 40 public import soup.c.types; 41 42 43 /** 44 * A request to retrieve a particular URI. 45 * 46 * Since: 2.42 47 */ 48 public class Request : ObjectG, InitableIF 49 { 50 /** the main Gtk struct */ 51 protected SoupRequest* soupRequest; 52 53 /** Get the main Gtk struct */ 54 public SoupRequest* getRequestStruct(bool transferOwnership = false) 55 { 56 if (transferOwnership) 57 ownedRef = false; 58 return soupRequest; 59 } 60 61 /** the main Gtk struct as a void* */ 62 protected override void* getStruct() 63 { 64 return cast(void*)soupRequest; 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (SoupRequest* soupRequest, bool ownedRef = false) 71 { 72 this.soupRequest = soupRequest; 73 super(cast(GObject*)soupRequest, ownedRef); 74 } 75 76 // add the Initable capabilities 77 mixin InitableT!(SoupRequest); 78 79 80 /** */ 81 public static GType getType() 82 { 83 return soup_request_get_type(); 84 } 85 86 /** 87 * Gets the length of the data represented by @request. For most 88 * request types, this will not be known until after you call 89 * soup_request_send() or soup_request_send_finish(). 90 * 91 * Returns: the length of the data represented by @request, 92 * or -1 if not known. 93 * 94 * Since: 2.42 95 */ 96 public long getContentLength() 97 { 98 return soup_request_get_content_length(soupRequest); 99 } 100 101 /** 102 * Gets the type of the data represented by @request. For most request 103 * types, this will not be known until after you call 104 * soup_request_send() or soup_request_send_finish(). 105 * 106 * As in the HTTP Content-Type header, this may include parameters 107 * after the MIME type. 108 * 109 * Returns: the type of the data represented by 110 * @request, or %NULL if not known. 111 * 112 * Since: 2.42 113 */ 114 public string getContentType() 115 { 116 return Str.toString(soup_request_get_content_type(soupRequest)); 117 } 118 119 /** 120 * Gets @request's #SoupSession 121 * 122 * Returns: @request's #SoupSession 123 * 124 * Since: 2.42 125 */ 126 public Session getSession() 127 { 128 auto __p = soup_request_get_session(soupRequest); 129 130 if(__p is null) 131 { 132 return null; 133 } 134 135 return ObjectG.getDObject!(Session)(cast(SoupSession*) __p); 136 } 137 138 /** 139 * Gets @request's URI 140 * 141 * Returns: @request's URI 142 * 143 * Since: 2.42 144 */ 145 public URI getUri() 146 { 147 auto __p = soup_request_get_uri(soupRequest); 148 149 if(__p is null) 150 { 151 return null; 152 } 153 154 return ObjectG.getDObject!(URI)(cast(SoupURI*) __p); 155 } 156 157 /** 158 * Synchronously requests the URI pointed to by @request, and returns 159 * a #GInputStream that can be used to read its contents. 160 * 161 * Note that you cannot use this method with #SoupRequests attached to 162 * a #SoupSessionAsync. 163 * 164 * Params: 165 * cancellable = a #GCancellable or %NULL 166 * 167 * Returns: a #GInputStream that can be used to 168 * read from the URI pointed to by @request. 169 * 170 * Since: 2.42 171 * 172 * Throws: GException on failure. 173 */ 174 public InputStream send(Cancellable cancellable) 175 { 176 GError* err = null; 177 178 auto __p = soup_request_send(soupRequest, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 179 180 if (err !is null) 181 { 182 throw new GException( new ErrorG(err) ); 183 } 184 185 if(__p is null) 186 { 187 return null; 188 } 189 190 return ObjectG.getDObject!(InputStream)(cast(GInputStream*) __p, true); 191 } 192 193 /** 194 * Begins an asynchronously request for the URI pointed to by 195 * @request. 196 * 197 * Note that you cannot use this method with #SoupRequests attached to 198 * a #SoupSessionSync. 199 * 200 * Params: 201 * cancellable = a #GCancellable or %NULL 202 * callback = a #GAsyncReadyCallback 203 * userData = user data passed to @callback 204 * 205 * Since: 2.42 206 */ 207 public void sendAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 208 { 209 soup_request_send_async(soupRequest, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 210 } 211 212 /** 213 * Gets the result of a soup_request_send_async(). 214 * 215 * Params: 216 * result = the #GAsyncResult 217 * 218 * Returns: a #GInputStream that can be used to 219 * read from the URI pointed to by @request. 220 * 221 * Since: 2.42 222 * 223 * Throws: GException on failure. 224 */ 225 public InputStream sendFinish(AsyncResultIF result) 226 { 227 GError* err = null; 228 229 auto __p = soup_request_send_finish(soupRequest, (result is null) ? null : result.getAsyncResultStruct(), &err); 230 231 if (err !is null) 232 { 233 throw new GException( new ErrorG(err) ); 234 } 235 236 if(__p is null) 237 { 238 return null; 239 } 240 241 return ObjectG.getDObject!(InputStream)(cast(GInputStream*) __p, true); 242 } 243 }